{% set pypi_name = 'oslo.upgradecheck' %}
{% set upstream_version = upstream_version('1.2.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Epoch:          {{ epoch( pypi_name ) }}
Summary:        Common code for writing OpenStack upgrade checks
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  fdupes
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('Babel') }}
BuildRequires:  {{ py3('PrettyTable') }}
BuildRequires:  {{ py3('oslo.config') }}
BuildRequires:  {{ py3('oslo.i18n') }}
BuildRequires:  {{ py3('oslo.serialization') }}
BuildRequires:  {{ py3('oslo.utils') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('stestr') }}
BuildArch:      noarch

%description
This project contains the common code necessary for writing upgrade checks
in OpenStack projects. It includes a module (oslo_upgradecheck.upgradecheck)
for the common code as well as an example (oslo_upgradecheck.__main__) of
integrating that code into a project.

%package -n {{ py2name(py_versions='py3') }}
Summary:        Common code for writing OpenStack upgrade checks
Requires:       {{ py3('Babel') }}
Requires:       {{ py3('PrettyTable') }}
Requires:       {{ py3('oslo.config') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('oslo.utils') }}

%description -n {{ py2name(py_versions='py3') }}
This project contains the common code necessary for writing upgrade checks
in OpenStack projects. It includes a module (oslo_upgradecheck.upgradecheck)
for the common code as well as an example (oslo_upgradecheck.__main__) of
integrating that code into a project.

This package contains the Python 3.x module.

%package -n python-{{ pypi_name }}-doc
Summary:        Common code for writing OpenStack upgrade checks
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}

%description -n python-{{ pypi_name }}-doc
Documentation for the {{ pypi_name }} library.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}

PBR_VERSION={{ upstream_version }} %sphinx_build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}
%fdupes doc/build/html/

%install
%{py3_install}

%check
export PYTHONPATH=`pwd`
python3 -m stestr.cli run

%files -n {{ py2name(py_versions='py3') }}
%license LICENSE
%{python3_sitelib}/oslo_upgradecheck
%{python3_sitelib}/*.egg-info

%files -n python-{{ pypi_name }}-doc
%doc doc/build/html README.rst
%license LICENSE

%changelog
